package edu.ccut.saturn.basevalidate.prvalidate;

import edu.ccut.saturn.component.DefaultSaturnValidate;
import edu.ccut.saturn.component.ValidateResult;

public class CheckLengthValidate extends DefaultSaturnValidate {

	public void doValidate(Object value, Object[] args, ValidateResult result) {
		
		if (args != null && args.length >= 2) {
			
			int floor = Integer.parseInt(args[0].toString());
			int top = Integer.parseInt(args[1].toString());
			
			if ((value.toString()).length() < floor|| (value.toString()).length() > top) {
				sendError(_ERROR_, value, result);
			}
		}else{
			sendError(_ARGERROR_, value, result);
		}
	}
}
